package com.clutch.student;
/**
 * 修改个人信息界面
 */

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RadioButton;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import android.widget.Toast;

import com.clutch.student.Adapter.CourseSecAdapter;
import com.clutch.student.Adapter.MYCourseAdapter;
import com.clutch.student.Adapter.StudentAdapter;
import com.clutch.student.Dao.ScoreDao;
import com.clutch.student.Dao.StudentDao;
import com.clutch.student.Entity.CourseSec;
import com.clutch.student.Entity.Student;
import com.clutch.student.Entity.Student_info;
import com.facebook.stetho.inspector.database.SqliteDatabaseDriver;

import java.sql.SQLData;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.xml.transform.Source;


public class MySourseActivity extends AppCompatActivity implements View.OnClickListener{


    static Context context = MyApplication.getInstance();
    private static ScoreDao course = new ScoreDao(context);
    private static RecyclerView recyclerView;
    private static TextView emptyText;
    private static List<CourseSec> CourseList;

    ImageView back_btn;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.mysourse);

        //返回
        back_btn = findViewById(R.id.back_btn);
        back_btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });

        emptyText = (TextView) findViewById(R.id.empty_text);      //用于在无数据时进行提示
        CourseList = course.getScore(MainActivity.getStudentId());      //获取已选课程的List

        recyclerView = findViewById(R.id.recycler_view_mysourse);
        if(CourseList==null){
            //若数据为空，则显示emptyText,隐藏recyclerView
            emptyText.setVisibility(View.VISIBLE);
            recyclerView.setVisibility(View.GONE);
        }else {
            LinearLayoutManager layoutManager = new LinearLayoutManager(context);       //线性布局
            recyclerView.setLayoutManager(layoutManager);                               //RecyclerView加载线性布局
            CourseSecAdapter adapter = new CourseSecAdapter(CourseList);                //创建课程类适配器，参数为刚查询到的存有课程信息的CourseList
            recyclerView.setAdapter(adapter);                                           //将适配器加载入recyclerView中
            //为RecyclerView中的每一项加分割线
            DividerItemDecoration mDividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(),layoutManager.getOrientation());
            recyclerView.addItemDecoration(mDividerItemDecoration);
        }




        //从数据库中取出数据



    }




    @Override
    public void onClick(View view) {

    }
}
